package springAop.animotion;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

/**
 * Created by mHandler on 2018/6/27 0027.
 * Description:
 */

public class TestAnimotion {



    public static void main(String[] args){
        CustomerDao customerDao;
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        customerDao = (CustomerDao) context.getBean("customerDaoImpl");
        customerDao.save();
        customerDao.update();

        //jdbc连接代码实现
//        DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
//        driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
//        driverManagerDataSource.setUrl("jdbc:mysql:///localhost:3306/mmall_learning?characterEncoding=utf-8");
//        driverManagerDataSource.setUsername("root");
//        driverManagerDataSource.setPassword("abc123");
//
//        JdbcTemplate template = new JdbcTemplate(driverManagerDataSource);
//        template.execute("");

        //ioc方式实现
        JdbcTemplate template = (JdbcTemplate) context.getBean("template");
        template.execute("");
    }
}
